package bob.project;

import java.io.File;
import java.lang.reflect.Field;

import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.SlickException;

import bob.project.slick.Game;

public class Loader {

	/**
	 * @param args
	 * @throws SlickException 
	 * @throws IllegalAccessException 
	 * @throws IllegalArgumentException 
	 * @throws NoSuchFieldException 
	 * @throws SecurityException 
	 */
	public static void main(String[] args) throws SlickException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException
	{
		prepareSystem();
		AppGameContainer app = new AppGameContainer(new Game("Project Bob"));
		app.setDisplayMode(800, 600, false);
		app.setTargetFrameRate(60);
		app.setShowFPS(false);
		app.start();
	}
	
	static void prepareSystem() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException
	{
		System.setProperty( "java.class.path", "."+File.separator+"lib"+File.separator );
		if (System.getProperties().getProperty("os.name").contains("Windows"))
			System.setProperty( "java.library.path", "."+File.separator+"native"+File.separator+"win"+File.separator);
		else if (System.getProperties().getProperty("os.name").contains("Mac"))
			System.setProperty( "java.library.path", "."+File.separator+"native"+File.separator+"mac"+File.separator);		
		else if (System.getProperties().getProperty("os.name").contains("Linux"))
			System.setProperty( "java.library.path", "native"+File.separator+"lin"+File.separator+"" );
		System.out.println(System.getProperties().get("java.library.path"));
		System.out.println(System.getProperties().get("java.class.path"));
		Field fieldSysPath = ClassLoader.class.getDeclaredField( "sys_paths" );
		fieldSysPath.setAccessible( true );
		fieldSysPath.set( null, null );
	}

}
